<?php

if (file_exists(APPPATH.'models/basemodel.php')) include_once(APPPATH.'models/basemodel.php');

class AddressesModel extends BaseModel {
	
	public function AddressesModel() {
		parent::BaseModel();
		$this->setModel('address');
		$this->obj =& get_instance();
		$this->load->database();
	}
	
	public function retrieve_by_pkey($id) {
		$sql = "SELECT A.*, C.printable_name as country
				FROM address A LEFT JOIN country C ON (A.countryid = C.id)
				WHERE A.deleted = 0 ";
				
		$sql .= " AND A.id = ".intval($id);
		
		$sql .= " LIMIT 1";
				
		$rs = $this->db->query($sql)->result();
		
		if (count($rs)) return $rs[0];
		else return false;
	}

}

?>